<?php
	require_once('../auth.php');

?>

<html>
<head>
<script language="javascript">
location.replace("../adminhome.php")

</script>

</head>
<body>
<?php
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
	
	
if(($_FILES["file"]["size"])>0)
{ 
$name=$_FILES["file"]["name"];
$img="files/";
$img.=$_FILES["file"]["name"];
$img2=$_FILES["file"]["size"];

if(($_FILES["file"]["size"])>0)
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("files/" . $_FILES["file"]["name"]))
      {
/*     echo $_FILES["file"]["name"] . " already exists. ";
*/      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "files/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "files/" . $_FILES["file"]["name"];
      }
    }
 }
else
  {
  echo "Invalid file";
  }
echo "success";
}
?> 




<?php
if($img2>0)
{
$con = mysql_connect("localhost","appma" ,"database");
	mysql_select_db("162_appma", $con);
$sql="INSERT INTO  files VALUES ('$name', '$_POST[catagory]')";
mysql_query($sql,$con);  
}
?>

</body>
</html>